<?php

namespace common\models\mdm;

use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use common\models\mdm\MdmOrg;

/**
 * MdmOrgSearch represents the model behind the search form about `common\models\mdm\MdmOrg`.
 */
class MdmOrgSearch extends MdmOrg
{
    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['PK_ORG', 'PK_GROUP', 'PK_ORG_V', 'PK_MDM_ORG', 'ORGCODE', 'ORGNAME', 'ORGORDERNAME', 'YYZZCODE', 'ORGCODECERT', 'BUSSCOPE', 'CSDJCODE', 'DSDJCODE', 'SETUPDATE', 'PROPBLUFD', 'CGBLUFD', 'ZCZEMONEY', 'HSMETHOD', 'STARTDATE', 'ENDDATE', 'ZCCAPUDF', 'SCCAPUFD', 'FRDBPOP', 'TXADRESS', 'ZIPCODE', 'PHONE', 'FAXCODE', 'COMPLXPOP', 'COMPINTRO', 'CREATOR', 'CREATIONTIME', 'MODIFIER', 'MODIFIEDTIME', 'VAPPROVEID', 'DAPPROVEDATE', 'VAPPROVENOTE', 'BILLCODE', 'TRANSTYPE', 'TRANSTYPEID', 'PK_BILLTYPE', 'PK_BUSITYPE', 'PK_DEF1', 'PK_DEF2', 'PK_DEF3', 'PK_DEF4', 'PK_DEF5', 'PK_DEF6', 'PK_DEF7', 'PK_DEF8', 'PK_DEF9', 'PK_DEF10', 'VVDEF1', 'VVDEF2', 'VVDEF3', 'VVDEF4', 'VVDEF5', 'VVDEF6', 'VVDEF7', 'VVDEF8', 'VVDEF9', 'VVDEF10', 'VVDEF11', 'VVDEF12', 'VVDEF13', 'VVDEF14', 'VVDEF15', 'VVDEF16', 'VVDEF17', 'VVDEF18', 'VVDEF19', 'VVDEF20', 'VVDEF21', 'VVDEF22', 'VVDEF23', 'VVDEF24', 'VVDEF25', 'VVDEF26', 'VVDEF27', 'VVDEF28', 'VVDEF29', 'VVDEF30', 'DDEF1', 'DDEF2', 'DDEF3', 'DDEF4', 'DDEF5', 'DDEF6', 'DDEF7', 'DDEF8', 'DDEF9', 'DDEF10', 'BDEF1', 'BDEF2', 'BDEF3', 'BDEF4', 'BDEF5', 'BDEF6', 'BDEF7', 'BDEF8', 'BDEF9', 'BDEF10', 'ISNOTUSE', 'NOTUSEDATE', 'NOTUSEMAN', 'ISVIRTUAL', 'MAINBODY', 'TS'], 'safe'],
            [['BILLSTATUS', 'IDEF1', 'IDEF2', 'IDEF3', 'IDEF4', 'IDEF5', 'IDEF6', 'IDEF7', 'IDEF8', 'IDEF9', 'IDEF10', 'INVESTMENT', 'TIMES', 'DR'], 'integer'],
            [['NDEF1', 'NDEF2', 'NDEF3', 'NDEF4', 'NDEF5', 'NDEF6', 'NDEF7', 'NDEF8', 'NDEF9', 'NDEF10', 'MONEY', 'PERCENT'], 'number'],
        ];
    }

    /**
     * @inheritdoc
     */
    public function scenarios()
    {
        // bypass scenarios() implementation in the parent class
        return Model::scenarios();
    }

    /**
     * Creates data provider instance with search query applied
     *
     * @param array $params
     *
     * @return ActiveDataProvider
     */
    public function search($params)
    {
        $query = MdmOrg::find();

        // add conditions that should always apply here

        $dataProvider = new ActiveDataProvider([
            'query' => $query,
        ]);

        $this->load($params);

        if (!$this->validate()) {
            // uncomment the following line if you do not want to return any records when validation fails
            // $query->where('0=1');
            return $dataProvider;
        }

        // grid filtering conditions
        $query->andFilterWhere([
            'BILLSTATUS' => $this->BILLSTATUS,
            'IDEF1' => $this->IDEF1,
            'IDEF2' => $this->IDEF2,
            'IDEF3' => $this->IDEF3,
            'IDEF4' => $this->IDEF4,
            'IDEF5' => $this->IDEF5,
            'IDEF6' => $this->IDEF6,
            'IDEF7' => $this->IDEF7,
            'IDEF8' => $this->IDEF8,
            'IDEF9' => $this->IDEF9,
            'IDEF10' => $this->IDEF10,
            'NDEF1' => $this->NDEF1,
            'NDEF2' => $this->NDEF2,
            'NDEF3' => $this->NDEF3,
            'NDEF4' => $this->NDEF4,
            'NDEF5' => $this->NDEF5,
            'NDEF6' => $this->NDEF6,
            'NDEF7' => $this->NDEF7,
            'NDEF8' => $this->NDEF8,
            'NDEF9' => $this->NDEF9,
            'NDEF10' => $this->NDEF10,
            'INVESTMENT' => $this->INVESTMENT,
            'TIMES' => $this->TIMES,
            'MONEY' => $this->MONEY,
            'PERCENT' => $this->PERCENT,
            'DR' => $this->DR,
        ]);

        $query->andFilterWhere(['like', 'PK_ORG', $this->PK_ORG])
            ->andFilterWhere(['like', 'PK_GROUP', $this->PK_GROUP])
            ->andFilterWhere(['like', 'PK_ORG_V', $this->PK_ORG_V])
            ->andFilterWhere(['like', 'PK_MDM_ORG', $this->PK_MDM_ORG])
            ->andFilterWhere(['like', 'ORGCODE', $this->ORGCODE])
            ->andFilterWhere(['like', 'ORGNAME', $this->ORGNAME])
            ->andFilterWhere(['like', 'ORGORDERNAME', $this->ORGORDERNAME])
            ->andFilterWhere(['like', 'YYZZCODE', $this->YYZZCODE])
            ->andFilterWhere(['like', 'ORGCODECERT', $this->ORGCODECERT])
            ->andFilterWhere(['like', 'BUSSCOPE', $this->BUSSCOPE])
            ->andFilterWhere(['like', 'CSDJCODE', $this->CSDJCODE])
            ->andFilterWhere(['like', 'DSDJCODE', $this->DSDJCODE])
            ->andFilterWhere(['like', 'SETUPDATE', $this->SETUPDATE])
            ->andFilterWhere(['like', 'PROPBLUFD', $this->PROPBLUFD])
            ->andFilterWhere(['like', 'CGBLUFD', $this->CGBLUFD])
            ->andFilterWhere(['like', 'ZCZEMONEY', $this->ZCZEMONEY])
            ->andFilterWhere(['like', 'HSMETHOD', $this->HSMETHOD])
            ->andFilterWhere(['like', 'STARTDATE', $this->STARTDATE])
            ->andFilterWhere(['like', 'ENDDATE', $this->ENDDATE])
            ->andFilterWhere(['like', 'ZCCAPUDF', $this->ZCCAPUDF])
            ->andFilterWhere(['like', 'SCCAPUFD', $this->SCCAPUFD])
            ->andFilterWhere(['like', 'FRDBPOP', $this->FRDBPOP])
            ->andFilterWhere(['like', 'TXADRESS', $this->TXADRESS])
            ->andFilterWhere(['like', 'ZIPCODE', $this->ZIPCODE])
            ->andFilterWhere(['like', 'PHONE', $this->PHONE])
            ->andFilterWhere(['like', 'FAXCODE', $this->FAXCODE])
            ->andFilterWhere(['like', 'COMPLXPOP', $this->COMPLXPOP])
            ->andFilterWhere(['like', 'COMPINTRO', $this->COMPINTRO])
            ->andFilterWhere(['like', 'CREATOR', $this->CREATOR])
            ->andFilterWhere(['like', 'CREATIONTIME', $this->CREATIONTIME])
            ->andFilterWhere(['like', 'MODIFIER', $this->MODIFIER])
            ->andFilterWhere(['like', 'MODIFIEDTIME', $this->MODIFIEDTIME])
            ->andFilterWhere(['like', 'VAPPROVEID', $this->VAPPROVEID])
            ->andFilterWhere(['like', 'DAPPROVEDATE', $this->DAPPROVEDATE])
            ->andFilterWhere(['like', 'VAPPROVENOTE', $this->VAPPROVENOTE])
            ->andFilterWhere(['like', 'BILLCODE', $this->BILLCODE])
            ->andFilterWhere(['like', 'TRANSTYPE', $this->TRANSTYPE])
            ->andFilterWhere(['like', 'TRANSTYPEID', $this->TRANSTYPEID])
            ->andFilterWhere(['like', 'PK_BILLTYPE', $this->PK_BILLTYPE])
            ->andFilterWhere(['like', 'PK_BUSITYPE', $this->PK_BUSITYPE])
            ->andFilterWhere(['like', 'PK_DEF1', $this->PK_DEF1])
            ->andFilterWhere(['like', 'PK_DEF2', $this->PK_DEF2])
            ->andFilterWhere(['like', 'PK_DEF3', $this->PK_DEF3])
            ->andFilterWhere(['like', 'PK_DEF4', $this->PK_DEF4])
            ->andFilterWhere(['like', 'PK_DEF5', $this->PK_DEF5])
            ->andFilterWhere(['like', 'PK_DEF6', $this->PK_DEF6])
            ->andFilterWhere(['like', 'PK_DEF7', $this->PK_DEF7])
            ->andFilterWhere(['like', 'PK_DEF8', $this->PK_DEF8])
            ->andFilterWhere(['like', 'PK_DEF9', $this->PK_DEF9])
            ->andFilterWhere(['like', 'PK_DEF10', $this->PK_DEF10])
            ->andFilterWhere(['like', 'VVDEF1', $this->VVDEF1])
            ->andFilterWhere(['like', 'VVDEF2', $this->VVDEF2])
            ->andFilterWhere(['like', 'VVDEF3', $this->VVDEF3])
            ->andFilterWhere(['like', 'VVDEF4', $this->VVDEF4])
            ->andFilterWhere(['like', 'VVDEF5', $this->VVDEF5])
            ->andFilterWhere(['like', 'VVDEF6', $this->VVDEF6])
            ->andFilterWhere(['like', 'VVDEF7', $this->VVDEF7])
            ->andFilterWhere(['like', 'VVDEF8', $this->VVDEF8])
            ->andFilterWhere(['like', 'VVDEF9', $this->VVDEF9])
            ->andFilterWhere(['like', 'VVDEF10', $this->VVDEF10])
            ->andFilterWhere(['like', 'VVDEF11', $this->VVDEF11])
            ->andFilterWhere(['like', 'VVDEF12', $this->VVDEF12])
            ->andFilterWhere(['like', 'VVDEF13', $this->VVDEF13])
            ->andFilterWhere(['like', 'VVDEF14', $this->VVDEF14])
            ->andFilterWhere(['like', 'VVDEF15', $this->VVDEF15])
            ->andFilterWhere(['like', 'VVDEF16', $this->VVDEF16])
            ->andFilterWhere(['like', 'VVDEF17', $this->VVDEF17])
            ->andFilterWhere(['like', 'VVDEF18', $this->VVDEF18])
            ->andFilterWhere(['like', 'VVDEF19', $this->VVDEF19])
            ->andFilterWhere(['like', 'VVDEF20', $this->VVDEF20])
            ->andFilterWhere(['like', 'VVDEF21', $this->VVDEF21])
            ->andFilterWhere(['like', 'VVDEF22', $this->VVDEF22])
            ->andFilterWhere(['like', 'VVDEF23', $this->VVDEF23])
            ->andFilterWhere(['like', 'VVDEF24', $this->VVDEF24])
            ->andFilterWhere(['like', 'VVDEF25', $this->VVDEF25])
            ->andFilterWhere(['like', 'VVDEF26', $this->VVDEF26])
            ->andFilterWhere(['like', 'VVDEF27', $this->VVDEF27])
            ->andFilterWhere(['like', 'VVDEF28', $this->VVDEF28])
            ->andFilterWhere(['like', 'VVDEF29', $this->VVDEF29])
            ->andFilterWhere(['like', 'VVDEF30', $this->VVDEF30])
            ->andFilterWhere(['like', 'DDEF1', $this->DDEF1])
            ->andFilterWhere(['like', 'DDEF2', $this->DDEF2])
            ->andFilterWhere(['like', 'DDEF3', $this->DDEF3])
            ->andFilterWhere(['like', 'DDEF4', $this->DDEF4])
            ->andFilterWhere(['like', 'DDEF5', $this->DDEF5])
            ->andFilterWhere(['like', 'DDEF6', $this->DDEF6])
            ->andFilterWhere(['like', 'DDEF7', $this->DDEF7])
            ->andFilterWhere(['like', 'DDEF8', $this->DDEF8])
            ->andFilterWhere(['like', 'DDEF9', $this->DDEF9])
            ->andFilterWhere(['like', 'DDEF10', $this->DDEF10])
            ->andFilterWhere(['like', 'BDEF1', $this->BDEF1])
            ->andFilterWhere(['like', 'BDEF2', $this->BDEF2])
            ->andFilterWhere(['like', 'BDEF3', $this->BDEF3])
            ->andFilterWhere(['like', 'BDEF4', $this->BDEF4])
            ->andFilterWhere(['like', 'BDEF5', $this->BDEF5])
            ->andFilterWhere(['like', 'BDEF6', $this->BDEF6])
            ->andFilterWhere(['like', 'BDEF7', $this->BDEF7])
            ->andFilterWhere(['like', 'BDEF8', $this->BDEF8])
            ->andFilterWhere(['like', 'BDEF9', $this->BDEF9])
            ->andFilterWhere(['like', 'BDEF10', $this->BDEF10])
            ->andFilterWhere(['like', 'ISNOTUSE', $this->ISNOTUSE])
            ->andFilterWhere(['like', 'NOTUSEDATE', $this->NOTUSEDATE])
            ->andFilterWhere(['like', 'NOTUSEMAN', $this->NOTUSEMAN])
            ->andFilterWhere(['like', 'ISVIRTUAL', $this->ISVIRTUAL])
            ->andFilterWhere(['like', 'MAINBODY', $this->MAINBODY])
            ->andFilterWhere(['like', 'TS', $this->TS]);

        return $dataProvider;
    }
}
